std::basic_fstream::basic_fstream

From Cppreference

Jump to: navigation, search
​basic_fstream( const char *filename,
               ios_base::openmode mode = ios_base::in|ios_base::out );
(1)
​basic_fstream( const string &filename,                                  
               ios_base::openmode mode = ios_base::in|ios_base::out );
(2) (C++0x)
​basic_fstream( basic_fstream&& other );
(3) (C++0x)

Constructs new file stream.

1-2) Associates the stream with a file after the constriction. Calls ​clear() on success or ​setstate(failbit) on failure.

The first version effectively calls ​rdbuf()->open(filename, mode).

The second version effectively calls ​open(filename.c_str(), mode).

3) Move constructor. Constructs the file stream with the state of other using move semantics.

Parameters

filename - the name of the file to be opened
mode - specifies stream open mode. It is bitmask type, the following constants are defined:
Constant Explanation
app seek to the end of stream before each write
binary open in binary mode
in open for reading
out open for writing
trunc discard the contents of the stream when opening
ate seek to the end of stream immediately after open
other - another file stream to use as source

Example

See also

open
opens a file and associates it with the stream
(public member function)
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox
In other languages